package com.thread;

public class Test21 {
    private static Object A=new Object();
    private static Object B=new Object();
    public static void main(String[] args) {

        new Thread(()->{
            synchronized (A){
                System.out.println("正在t1");
                try {
                    Thread.sleep(1);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                synchronized (B){
                    System.out.println("进来了");
                }
            }

        },"t1").start();


        new Thread(()->{
            synchronized (B){
                System.out.println("正在t2");
                try {
                    Thread.sleep(1);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                synchronized (A){
                    System.out.println("进来了");
                }
            }

        },"t2").start();


    }
}
